begintalkscript;

variables;

int i,j,k,r1,choice;

begintalknode 1;
        state = -1;
        personality = 6;
        nextstate = 1;
        condition = 1;
        question = "";
        text1 = "This innkeeper is a tall, brown haired man. He looks happy to have a potential customer.";
        text2 = "He quickly says _I'm Moriros. Business has been slow lately._";
        text5 = "Moriros is busy polishing glasses. He stops to talk to you, hoping that you'll patronize his inn.";
        action = INTRO;
begintalknode 2;
        state = 1;
        personality = 6;
        nextstate = 3;
        condition = get_flag(0,0) < 3;
        question = "Why has business been slow?";
        text1 = "_The nephilim have driven most people out of this area, and one of my frequent customers has disappeared recently._";
        text2 = "";
        text3 = "";
        text4 = "";
        text5 = "";
begintalknode 3;
        state = 1;
        personality = 6;
        nextstate = 2;
        condition = 1;
        question = "What services do you offer?";
        text1 = "_I will sell you a drink for 5 coins, and a room costs 15 coins._";
        text2 = "_I don't sell food, but you can buy some from Aldnala, who is in the shop just to the south._";
begintalknode 4;
        state = 2;
        personality = 6;
        nextstate = -1;
        condition = 1;
        question = "I'd like a room.";
        text1 = "Moriros shows you to your room. You have a good rest, considering the constant shouts from outside.";
        text3 = "Unfortunately, you don't have enough gold to pay for the room.";
        text5 = "You are on horseback and can't stay in the inn.";
        action = INN 15 18 21;
        code =
                set_ticks_forward(150);
                break;
begintalknode 5;
        state = 2;
        personality = 6;
        nextstate = -1;
        condition = 1;
        question = "I'd like a drink.";
        text1 = "Moriros serves you a glass of fruit juice. It tastes strong.";
        text3 = "Unfortunately, you don't have enough gold to pay for the drink.";
        action = PAY -1 -1 -1 5;
begintalknode 6;
        state = 3;
        personality = 6;
        nextstate = -1;
        condition = get_flag(0,0) < 2;
        question = "You mentioned that one of your customers has disappeared.";
        text1 = "_Two days ago, he went to a hut in the southwest corner of this valley, and hasn't been heard from since. I'd really like to know what happened. His name was Doust_.";
        code = 
                toggle_quest(2,1);
                set_flag(0,0,1);
                break;
begintalknode 7;
        state = 3;
        personality = 6;
        nextstate = -1;
        condition = get_flag(0,0) == 2;
        question = "We found Doust. He's working in a hut to the southwest.";
        text1 = "He seems relieved. _I'm glad to hear that he's safe._";
        code = 
                toggle_quest(2,0);
                set_flag(0,0,3);
                award_party_xp(120,30);
                break;

begintalknode 8;
        state = -1;
        personality = 17;
        nextstate = 4;
        condition = 1;
        question = "";
        text1 = "Vorroth is a short, fair-haired wizard who looks like he's spent a lot of time indoors.";
        text2 = "He's reading a book, and puts it down to speak with you.";
        text5 = "Vorroth puts down the book he was reading, and asks _Can I help you?_";
        action = INTRO;
begintalknode 9;
        state = 4;
        personality = 17;
        nextstate = 5;
        condition = 1;
        question = "What services do you offer?";
        text1 = "_I can identify items, for a fee. I also sell spells to those who can learn._";
begintalknode 10;
        state = 4;
        personality = 17;
        nextstate = 6;
        condition = get_flag(0,2) < 2;
        question = "What were you reading?";
        text1 = "_A book on creating powerful items. I'd like to make them, but the mithral bars I need never arrived._";
begintalknode 11;
        state = 6;
        personality = 17;
        nextstate = -1;
        condition = get_flag(0,2) == 0;
        question = "Maybe we could find the bars for you.";
        text1 = "_A courier was taking them from from the city to the northeast last week. She was found dead five days ago and they were gone. The bars must still be in this valley somewhere. There were three of them, and if you'd get them back, I'd be very grateful._";
        code = 
                toggle_quest(3,1);
                set_flag(0,2,1);
                break;
begintalknode 12;
        state = 6;
        personality = 17;
        nextstate = -1;
        condition = (has_special_item(2) == 1 || has_special_item(2) == 2) && (get_flag(0,2) ==1);
        question = "We've found some mithral bars. (Show them to him.)";
        text1 = "He looks at the bars, and says _These are the type of bars I need, but you don't have enough of them. I need all three. You've made good progress, however._";
begintalknode 13;
        state = 6;
        personality = 17;
        nextstate = -1;
        condition = (has_special_item(2) >= 3) && (get_flag(0,2) == 1);
        question = "We've found some mithral bars. (Show them to him.)";
        text1 = "He looks at the bars, and says _Good job! I can now make the items I want. Any future spells you buy from me will be at a deep discount._ He takes the bars from you.";
        code = 
                toggle_quest(3,0);
                set_flag(0,2,2);
                award_party_xp(800,70);
                change_spec_item(2,-3);
                break;
begintalknode 14;
        state = 5;
        personality = 17;
        nextstate = -1;
        condition = 1;
        question = "We need some items identified.";
        text1 = "He looks at your items, and says _I know what all of these items are. The cost for this information is 15 coins per item._";
        action = ID 15;
begintalknode 15;
        state = 5;
        personality = 17;
        nextstate = -1;
        condition = get_flag(0,2) < 2;
        question = "We'd like to purchase some spells.";
        text1 = "You finish shopping.";
        code = 
                begin_shop_mode("Vorroth's spells","Vorroth is a competent teacher, but you feel he's holding something back. He also charges high prices.",6,5,-1);
                break;
begintalknode 16;
        state = 5;
        personality = 17;
        nextstate = -1;
        condition = get_flag(0,2) == 2;
        question = "We'd like to purchase some spells.";
        text1 = "You finish shopping.";
        code = 
                begin_shop_mode("Vorroth's spells","Since you've helped Vorroth, he'll teach you all he knows, and cheaply.",7,0,-1);
                break;
begintalknode 17;
        state = 4;
        personality = 17;
        nextstate = -1;
        condition = has_special_item(0)) == 1 && get_flag(100,5) == 1;
        question = "We have a Vahnatai scroll, but can't translate it. Can you translate it? (Show him the scroll.)";
        text1 = "_Unfortunately, I don't know enough about the vahnatai language to be able to translate it. However, there is a hermit to the northwest, on the other side of the river, who can translate that note._";
        code = 
                set_flag(100,5,2);
                break;

begintalknode 18;
        state = -1;
        personality = 19;
        nextstate = 7;
        condition = 1;
        question = "";
        text1 = "Mayor Achtaiper is a short, slim man with gray hair. He seems to have aged a lot in the past few weeks.";
        text2 = "He says _Welcome, adventurers. I've been having nothing but trouble recently, and I need help._";
        text5 = "_Achtaiper looks like he's aged further since the last time you talked to him._";
        action = INTRO;
begintalknode 19;
        state = 7;
        personality = 19;
        nextstate = -1;
        condition = get_flag(150,0) == 0;
        question = "What troubles have you had?";
        text1 = "_A few weeks ago, strong nephilim raiders started to appear. They are wandering through this valley and attacking travellers._";
begintalknode 20;
        state = 7;
        personality = 19;
        nextstate = -1;
        condition = get_flag(150,0) != 0;
        question = "What troubles have you had?";
        text1 = "_The nephilim problem has disappeared, but rumors have spread that a vahnatai is responsible. This may mean more trouble to come._";
begintalknode 21;
        state = 7;
        personality = 19;
        nextstate = -1;
        condition = get_flag(150,0) == 0 && get_flag(0,9) == 0;
        question = "Is there anything we can do to help?";
        text1 = "_Yes, there is. A group of nephilim is camped south of the bridge to the northwest, and are spying on traffic._";
        text2 = "_I don't have enough troops to both protect the city and hunt them down. If you make this problem disappear, you will be rewarded._";
        code = 
                toggle_quest(4,1);
                set_flag(0,9,1);
                break;
begintalknode 22;
        state = 7;
        personality = 19;
        nextstate = -1;
        condition = get_flag(100,0) != 0 && get_flag(0,9) == 1;
        question = "The nephilim spies won't bother you again. (Explain what happened.)";
        text1 = "_At last, some good news. Thank you for your help._";
        text2 = "He goes into the back and returns with three potions, which he gives you.";
        code = 
                toggle_quest(4,0);
                set_flag(0,9,2);
                reward_give(234);
                reward_give(234);
                reward_give(234);
                award_party_xp(400,50);
                break;
begintalknode 23;
        state = 7;
        personality = 19;
        nextstate = -1;
        condition = get_flag(100,5) == 0;
        question = "I was sent here to eliminate the nephilim threat. Where should I start?";
        text1 = "He thinks for a moment. _A large group of nephilim was sighted to the northeast of here. Defeating them may yield a clue._";
begintalknode 39;
        state = 7;
        personality = 19;
        nextstate = -1;
        condition = get_flag(100,5) == 1;
        question = "I've beaten the nephilim to the northeast, and gotten a scroll. Where do I go from here?";
        text1 = "He considers this. _You'll need to find someone who can translate the scroll. Try asking Vorroth._";

begintalknode 24;
        state = -1;
        personality = 16;
        nextstate = 8;
        condition = 1;
        question = "";
        text1 = "Clemosryn is a short, bald woman who stands behind a counter with several sets of armor on it.";
        text2 = "She turns to you, and says _Is there anything you need?_";
        text5 = "Clemosryn is still standing behind the counter. She asks you _Do you want to purchase anything?_";
        action = INTRO;
begintalknode 28;
        state = 8;
        personality = 16;
        nextstate = -1;
        condition = 1;
        question = "We want to purchase some armor.";
        text1 = "You finish shopping.";
        code = 
                begin_shop_mode("Clemosryn's armor","Clemosryn's armor selection is good, but expensive. She will also buy your excess, identified items.",0,4,1);
                break;
begintalknode 29;
        state = 8;
        personality = 16;
        nextstate = -1;
        condition = 1;
        question = "We want to purchase some weapons.";
        text1 = "You finish shopping.";
        code = 
                begin_shop_mode("Clemosryn's weapons","Clemosryn's weapons selection is good, but expensive. She will also buy your excess, identified items.",1,4,1);
                break;

begintalknode 25;
        state = -1;
        personality = 15;
        nextstate = 9;
        condition = 1;
        question = "";
        text1 = "Aldnala is a tall, black-haired woman who sits behind a counter with some food on it. The store is cold, but not cold enough to be painful.";
        text2 = "She asks you _Is there any food you want to purchase?_";
        text5 = "Aldnala asks you _Is there any food you want to purchase?_";
        action = INTRO;
begintalknode 30;
        state = 9;
        personality = 15;
        nextstate = -1;
        condition = 0;
        question = "Why is this store cold?";
        text1 = "You finish shopping.";
begintalknode 31;
        state = 9;
        personality = 15;
        nextstate = -1;
        condition = 1;
        question = "Yes, we want to purchase some food.";
        text1 = "You finish shopping.";
        code = 
                begin_shop_mode("Aldnala's rations","Several different varieties of food are available in this store. The prices here are somewhat high.",5,3,-1);
                break;

begintalknode 26;
        state = -1;
        personality = 18;
        nextstate = 10;
        condition = 1;
        question = "";
        text1 = "Sotiaves is a middle-aged person with red hair. He is holding a bow, trying to get a feel for it.";
        text2 = "When he sees you, he puts the bow down and says _Welcome, adventurers. Would you like to purchase any arrows or bows?";
        text5 = "Sotiaves is still trying out the bow. He puts it down again and asks you if you'd like to purchase anything.";
        action = INTRO;
begintalknode 32;
        state = 10;
        personality = 18;
        nextstate = 11;
        condition = 1;
        question = "Is there something unusual about that bow?";
        text1 = "He thinks for a moment, and then says _Yes, there is. This bow seems to be made out of cavewood, but it's quality far exceeds those of the cavewood bows previously found._";
begintalknode 33;
        state = 11;
        personality = 18;
        nextstate = -1;
        condition = 1;
        question = "Where did that bow come from?";
        text1 = "He pauses, and then mentions that it was found on a nephilim archer killed last week by the town guard.";
        text2 = "This raises a mystery, as the nephilim wouldn't be able to create that type of item on their own.";
begintalknode 34;
        state = 10;
        personality = 18;
        nextstate = -1;
        condition = 1;
        question = "Can I purchase some missiles?";
        text1 = "You finish shopping.";
        code = 
                begin_shop_mode("Sotiaves's missiles","Sotiaves has a number of different types of missiles available for sale. The prices here are somewhat high.",3,4,-1);
                break;
//retired empire archer

begintalknode 27;
        state = -1;
        personality = 20;
        nextstate = 12;
        condition = 1;
        question = "";
        text1 = "Lyever is a short, brown-haired man who wears the robes of a priest. He seems to be worn out.";
        text2 = "He wearily approaches you, and quietly says _Do you need assistance?_";
        text5 = "Lyever is pacing around this temple, and still seems to be worn out.";
        action = INTRO;
begintalknode 35;
        state = 12;
        personality = 20;
        nextstate = -1;
        condition = 1;
        question = "Why are you worn out?";
        text1 = "He states _The nephilim strike here often, and one of the first places they get to is my temple. I need to cast spells to keep them away.";
begintalknode 36;
        state = 12;
        personality = 20;
        nextstate = 13;
        condition = 1;
        question = "What services do you offer?";
        text1 = "He states _I can heal people, and I can also teach priest spells. However, I have little time to spare, and so my services will come at a premium._";
        text2 = "_For example, healing will cost 400 coins. What would you like?_";
begintalknode 37;
        state = 13;
        personality = 20;
        nextstate = -1;
        condition = coins_amount() >= 400;
        question = "We need healing. (Pay 400 coins.)";
        text1 = "He takes your cash, and then concentrates for about a minute. All of you are fully restored.";
        code =
                play_sound(24);
                change_coins(-400);
                restore_pc(0);
                restore_pc(1);
                restore_pc(2);
                restore_pc(3);
                break;
begintalknode 38;
        state = 13;
        personality = 20;
        nextstate = -1;
        condition = 1;
        question = "We'd like to purchase priest spells.";
        text1 = "You finish your shopping.";
        code = 
                begin_shop_mode("Lyever's spells","Lyever is capable of teaching spells efficiently, but charges a lot for his time.",8,5,-1);
                break;